package com.fjh.springboot_01.mapper;

import com.fjh.springboot_01.pojo.TeacherInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeacherInfoMapper {
    @Insert("INSERT INTO teacher_info (user_id, real_name, birth_date, education, major, province, subjects, address, introduction, teaching_schedule, id_card_photo, certificate_photo, school) " +
            "VALUES (#{userId}, #{realName}, #{birthDate}, #{education}, #{major}, #{province}, #{subjects}, #{address}, #{introduction}, #{teachingSchedule}, #{idCardPhoto}, #{certificatePhoto}, #{school})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(TeacherInfo teacherInfo);

    @Select("SELECT * FROM teacher_info WHERE user_id = #{userId}")
    List<TeacherInfo> findByUserId(Integer userId);

    @Select("SELECT * FROM teacher_info")
    List<TeacherInfo> findAll();

    @Update("UPDATE teacher_info SET real_name=#{realName}, birth_date=#{birthDate}, education=#{education}, " +
            "major=#{major}, province=#{province}, subjects=#{subjects}, address=#{address}, " +
            "introduction=#{introduction}, teaching_schedule=#{teachingSchedule}, " +
            "id_card_photo=#{idCardPhoto}, certificate_photo=#{certificatePhoto}, school=#{school} " +
            "WHERE user_id=#{userId}")
    void update(TeacherInfo teacherInfo);

    @Delete("DELETE FROM teacher_info WHERE user_id = #{userId}")
    void deleteByUserId(Integer userId);
} 